package TeachLesson;

import com.jspsmart.upload.SmartUpload;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "downloadCourseWorkServlet")
public class downloadCourseWorkServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      //获取下载文件所需路径
        String filePath=request.getParameter("filePath");

      //创建smartUpload
        SmartUpload su=new SmartUpload();
      //初始化
        su.initialize(getServletConfig(),request,response);
        try {
            su.downloadFile(filePath);
        }catch (Exception e){
            e.printStackTrace();
        }

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       doPost(request,response);
    }
}
